package com.hkbigdata.datagovernance.utils;

import com.alibaba.fastjson.JSONObject;
import com.hkbigdata.datagovernance.meta.bean.TableMetaInfo;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
@Component("MyUtils")
public class myUtils {
     public static List<JSONObject> tableMetaInfoToJsonList(TableMetaInfo tableMetaInfo){
         //新建新建json对象列表
         List<JSONObject> colNameList =new ArrayList<>();
         //将tableMetaInfo.getColNameJson()转换为json对象
         JSONObject nameJsonObject=JSONObject.parseObject(tableMetaInfo.getColNameJson());
         //将nameJsonObject转换为数组形式，例：{"col1": "type1", "col2": "type2"}
         for (String key : nameJsonObject.keySet()) {
             JSONObject keyValueObject = new JSONObject();
             keyValueObject.put(key,nameJsonObject.get(key));
             colNameList.add(keyValueObject);
         }
         return colNameList;
     }
}
